import router from '@/router.js'
import { judgeIsCompany } from '@/api/modules/propertyRight.js'
// const arr = [
//   { value: '股份有限公司', code: '01' },
//   { value: '有限责任公司', code: '02' },
//   { value: '非公司制法人企业', code: '03' },
//   { value: '合伙企业', code: '04' },
//   { value: '分支机构', code: '05' }
// ]
const GMTToStr = (time) => {
  let date = new Date(time)
  let Str=date.getFullYear() + '-' +
  (date.getMonth() + 1) + '-' + 
  date.getDate() + ' '
  //  + 
  // date.getHours() + ':' + 
  // date.getMinutes() + ':' + 
  // date.getSeconds()
  return Str
}
export const tableDetailColumns = [
  {
    name: '公司代码',
    value: 'cmhkId',
    align: 'left',
    width: '150px'
  }, {
    name: '中文名称',
    value: 'companyChiName',
    align: 'left'
  }, {
    name: '英文名称',
    value: 'companyEngName',
    align: 'left',
  }, {
    name: '注册类型',
    value: 'registerName',
    align: 'left',
    width: '200px',
    // formatter(row) {
    //   let result = arr.find(item => {
    //     return item.code.toString() === row.registerType
    //   })
    //   return result.value
    // }
    formatter(row) {
      switch (row.registerType) {
        case '01':
          row.registerName = '股份有限公司'
          break
        case '02':
          row.registerName = '有限责任公司'
          break
        case '03':
          row.registerName = '非公司制法人企业'
          break
        case '04':
          row.registerName = '合伙企业'
          break
        case '05':
          row.registerName = '分支机构'
          break
      }
      return row.registerName
    }
  },
  {
    name: '公司状态',
    value: 'cmhkStatus',
    align: 'left',
    width: '80px',
    formatter(row) {
      switch (row.cmhkStatus) {
        case '10':
          row.cmhkStatus = '正常'
          break
        case '20':
          row.cmhkStatus = '注销'
          break
        case '30':
          row.cmhkStatus = '发起'
          break
        case '40':
          row.cmhkStatus = '并购'
          break
        case '50':
          row.cmhkStatus = '发起终止'
          break
        case '60':
          row.cmhkStatus = '并购终止'
          break
      }
      return row.cmhkStatus
    }
  }
]
// 治理机构
export const governingBodyColumns = [
  {
    name: '成员',
    value: 'member',
    align: 'left',
    minWidth: '160px',
    render(h, params) {
      return h('span', {
        // attrs: { class: 'router-link' },
        // props: {
        //   to: {
        //     name: 'naturalManage',
        //     query: { userId: params.row.userId }
        //   }
        // },
        style: {
          cursor: 'pointer',
          textDecoration: 'underline'
        },
        on: {
          click: () => {
            const flag = params.row.isPerson
            if (flag === '0') {
              const data = {
                companyName: params.row.member
              }
              judgeIsCompany(data).then(res => {
                if (res.data.data.companyType) {
                  const obj = res.data.data.result
                  let routeUrl = router.resolve({
                    path: '/detail',
                    query: obj
                  })
                  window.open(routeUrl.href, '_blank')
                } else {
                  let routeUrl = router.resolve({
                    path: '/legalManage',
                    query: { name: params.row.member }
                  })
                  window.open(routeUrl.href, '_blank')
                }
              })
            } else {
              let routeUrl = router.resolve({
                path: '/naturalManage',
                query: { name: params.row.member }
              })
              window.open(routeUrl.href, '_blank')
            }
          }
        }
      }, params.row.member)
    }
  },
  {
    name: '职务',
    value: 'duty',
    align: 'left',
    minWidth: '80px'
  },
  {
    name: '产生方式',
    value: 'produceMethod',
    align: 'left',
    minWidth: '140px'
  },
  {
    name: '委派股东',
    value: 'shareholderName',
    align: 'left',
    minWidth: '200px',
    render(h, params) {
      return h('span', {
        // attrs: { class: 'router-link' },
        // props: {
        //   to: {
        //     name: 'naturalManage',
        //     query: { userId: params.row.userId }
        //   }
        // },
        style: {
          cursor: 'pointer',
          textDecoration: 'underline'
        },
        on: {
          click: () => {
            const flag = params.row.isPerson
            if (flag === '0') {
              const data = {
                companyName: params.row.shareholderName
              }
              judgeIsCompany(data).then(res => {
                if (res.data.data.companyType) {
                  const obj = res.data.data.result
                  let routeUrl = router.resolve({
                    path: '/detail',
                    query: obj
                  })
                  window.open(routeUrl.href, '_blank')
                } else {
                  let routeUrl = router.resolve({
                    path: '/legalManage',
                    query: { name: params.row.shareholderName }
                  })
                  window.open(routeUrl.href, '_blank')
                }
              })
            } else {
              let routeUrl = router.resolve({
                path: '/naturalManage',
                query: { name: params.row.shareholderName }
              })
              window.open(routeUrl.href, '_blank')
            }
          }
        }
      }, params.row.shareholderName)
    }
  },
  {
    name: '任职日期',
    value: 'workDate',
    align: 'left',
    formatter(row) {
      return GMTToStr(row.workDate)
    }
  },
  {
    name: '卸职日期',
    value: 'resignDate',
    align: 'left',
    formatter(row) {
      return GMTToStr(row.workDate)
    }
  }
]
// 基本信息中弹窗表格
export const dialogTableColumns = [
  {
    name: '员工工号',
    value: 'psId',
    align: 'center'
  },
  {
    name: '中文名',
    value: 'chiName',
    align: 'center'
  },
  {
    name: '英文名',
    value: 'engName',
    align: 'center'
  },
  {
    name: '所属公司',
    value: 'companyName',
    align: 'center'
  }
]
export const contributionTableColumns = [
  {
    name: '股东隶属',
    value: 'shareholderBelong',
    align: 'center',
    minWidth: '130px'
  },
  {
    name: '股东',
    value: 'shareholder',
    align: 'left',
    minWidth: '200px',
    render(h, params) {
      return h('span', {
        // attrs: { class: 'router-link' },
        // props: {
        //   to: {
        //     name: 'naturalManage',
        //     query: { userId: params.row.userId }
        //   }
        // },
        style: {
          cursor: 'pointer',
          textDecoration: 'underline'
        },
        on: {
          click: () => {
            const flag = params.row.isPerson
            if (flag === '0') {
              const data = {
                companyName: params.row.shareholder
              }
              judgeIsCompany(data).then(res => {
                if (res.data.data.companyType) {
                  const obj = res.data.data.result
                  let routeUrl = router.resolve({
                    path: '/detail',
                    query: obj
                  })
                  window.open(routeUrl.href, '_blank')
                } else {
                  let routeUrl = router.resolve({
                    path: '/legalManage',
                    query: { name: params.row.shareholder }
                  })
                  window.open(routeUrl.href, '_blank')
                }
              })
            } else {
              let routeUrl = router.resolve({
                path: '/naturalManage',
                query: { name: params.row.shareholder }
              })
              window.open(routeUrl.href, '_blank')
            }
          }
        }
      }, params.row.shareholder)
    }
  },
  {
    name: '出资比例',
    value: 'subscribeOcPer',
    align: 'right'
  },
  {
    name: '委托人',
    value: 'consignerName',
    align: 'left',
  },
  {
    name: '认缴注册资本额(原币)',
    value: 'subscribeShareOc',
    align: 'right',
    minWidth: '180px'
  },
  {
    name: '实缴注册资本额(原币)',
    value: 'paidShareOc',
    align: 'right',
    minWidth: '180px'
  },
  {
    name: '实缴注册资本额(人民币)',
    value: 'paidShareRmb',
    align: 'right',
    minWidth: '190px'
  },
  {
    name: '表决权份额',
    value: 'voteShare',
    align: 'right',
    minWidth: '150px'
  },
  {
    name: '分红权份额',
    value: 'dividendShare',
    align: 'right',
    minWidth: '150px'
  }
]
export const shareTypeColumns = [
  {
    name: '股份类别',
    value: 'shareCategoryName',
    align: 'left',
    minWidth: '140px'
  },
  {
    name: '股份类型',
    value: 'shareTypeName',
    align: 'left'
  },
  {
    name: '上市交易所及板块',
    value: 'listedExchangeModule',
    align: 'left',
    minWidth: '140px'
  },
  {
    name: '交易类型',
    value: 'transactTypeName',
    align: 'left',
    minWidth: '140px'
  },
  {
    name: '是否有面值',
    value: 'isValue',
    align: 'left',
    minWidth: '120px'
  },
  {
    name: '每股面值（原币）',
    value: 'priceSharePerOc',
    align: 'left',
    minWidth: '140px'
  },
  {
    name: '交易币种',
    value: 'transactCurrency',
    align: 'left'
  },
  {
    name: '股票代码',
    value: 'shareCode',
    align: 'left'
  },
  {
    name: '股票简称',
    value: 'shareShortName',
    align: 'left',
    minWidth: '140px'
  },
  {
    name: '上市(挂牌)时间',
    value: 'startDate',
    align: 'left',
    minWidth: '140px'
  }
]
export const shareMsgColumns = [
  {
    name: '股东隶属',
    value: 'shareholderBelong',
    align: 'center',
    minWidth: '120px'
  },
  {
    name: '股东',
    value: 'shareholder',
    align: 'left',
    minWidth: '200px'
  },
  {
    name: '持股比例',
    value: 'subscribePer',
    align: 'right'
  },
  {
    name: '委托人',
    value: 'consignerName',
    align: 'left'
  },
  {
    name: '股份类别',
    value: 'shareCategoryName',
    align: 'left',
    minWidth: '130px'
  },
  {
    name: '每股面值(原币)',
    value: 'priceSharePerOc',
    align: 'right',
    minWidth: '120px'
  },
  {
    name: '上市交易所及板块',
    value: 'listedExchangeDes',
    align: 'left',
    minWidth: '140px'
  },
  {
    name: '证券账户',
    value: 'stockAccount',
    align: 'left',
    minWidth: '100px'
  },
  {
    name: '认购股份数',
    value: 'subscribeShare',
    align: 'right',
    minWidth: '150px'
  },
  {
    name: '认购股本(原币)',
    value: 'subscribeShareOc',
    align: 'right',
    minWidth: '150px'
  },
  {
    name: '已缴款股份数',
    value: 'paidShare',
    align: 'right',
    minWidth: '150px'
  },
  {
    name: '已缴款股本(原币)',
    value: 'paidShareOc',
    align: 'right',
    minWidth: '150px'
  },
  {
    name: '已缴款股本(人民币)',
    value: 'paidShareRmb',
    align: 'right',
    minWidth: '150px'
  },
  {
    name: '表决权份额',
    value: 'voteShare',
    align: 'right',
    minWidth: '150px'
  },
  {
    name: '分红权份额',
    value: 'dividendShare',
    align: 'right',
    minWidth: '150px'
  },
  {
    name: '有限售条件的股份数',
    value: 'limitShare',
    align: 'right',
    minWidth: '150px'
  },
  {
    name: '质押或冻结的股份数',
    value: 'pleFrz',
    align: 'right',
    minWidth: '150px'
  }
]
export const dialogTableColumnsComponty = [
  {
    name: '公司代码',
    value: 'code',
    align: 'center'
  },
  {
    name: '公司中文名',
    value: 'chiName',
    align: 'center'
  },
  {
    name: '公司英文名',
    value: 'engName',
    align: 'center'
  }
]
export const partnerColumns = [
  {
    name: '股东隶属',
    value: 'shareholderBelong',
    align: 'center',
    minWidth: '130px'
  },
  {
    name: '合伙人',
    value: 'shareholder',
    align: 'left',
    minWidth: '200px'
  },
  {
    name: '出资比例',
    value: 'subscribeOcPer',
    align: 'right'
  },
  {
    name: '委托人',
    value: 'consignerName',
    align: 'left'
  },
  {
    name: '认缴出资额(原币)',
    value: 'subscribeShareOc',
    align: 'right',
    minWidth: '150px'
  },
  {
    name: '实缴出资额(原币)',
    value: 'paidShareOc',
    align: 'right',
    minWidth: '150px'
  },
  {
    name: '实缴出资额(人民币)',
    value: 'paidShareRmb',
    align: 'right',
    minWidth: '170px'
  },
  {
    name: '表决权份额',
    value: 'voteShare',
    align: 'right',
    minWidth: '130px'
  },
  {
    name: '分红权份额',
    value: 'dividendShare',
    align: 'right',
    minWidth: '130px'
  },
  // {
  //   name: '出资方式',
  //   value: 'payTypeDes',
  //   align: 'left'
  // },
  // {
  //   name: '出资缴付期限',
  //   value: 'payLimitTime',
  //   align: 'left',
  //   minWidth: '130px'
  // }
]

// 直接投资五项表格列
export const shareholdColumns = [
  {
    name: '证券账户号码',
    value: 'accountNum',
    align: 'left',
    minWidth: '120px'
  },
  {
    name: '交易场所及板块',
    value: 'listedExchange',
    align: 'left',
    minWidth: '120px'
  },
  {
    name: '股票代码',
    value: 'shareCode',
    align: 'left'
  },
  {
    name: '股票简称',
    value: 'shareShortName',
    align: 'left',
  },
  {
    name: '股份类别',
    value: 'shareCategoryName',
    align: 'left'
  },
  {
    name: '持有股份数',
    value: 'subscribeShare',
    align: 'right',
    minWidth: '100px'
  },
  {
    name: '持股比例',
    value: 'shareholdingRatio',
    align: 'right'
  },
  {
    name: '有限售条件的股份数',
    value: 'limitShare',
    align: 'right',
    minWidth: '140px'
  },
  {
    name: '质押或冻结的股份数',
    value: 'pleFrz',
    align: 'right',
    minWidth: '120px'
  },


]
export const shareCompanyColumns = [
  {
    name: '公司代码',
    value: 'cmhkId',
    align: 'left'
  },
  {
    name: '中文名称',
    value: 'companyChiName',
    align: 'left',
    minWidth: '200px'
  },
  {
    name: '英文名称',
    value: 'companyEngName',
    align: 'left',
    minWidth: '200px'
  },
  {
    name: '所在地区',
    value: 'location',
    align: 'left',
    minWidth: '200px'
  },
  {
    name: '是否实体',
    value: 'entityDesc',
    align: 'left',
    formatter(row) {
      switch (row.isEntity) {
        case '0':
          row.entityDesc = '否'
          break
        case '1':
          row.entityDesc = '是'
          break
      }
      return row.entityDesc
    }
  },
  {
    name: '经营状况',
    value: 'statusDes',
    align: 'left'
  },
  {
    name: '会计核算类型',
    value: 'accountingTypeDes',
    align: 'left',
    minWidth: '120px'
  },
  {
    name: '入股日期',
    value: 'buyTime',
    align: 'left',
    minWidth: '120px'
  },
  {
    name: '委托人',
    value: 'consigner',
    align: 'left'
  },
  {
    name: '股份类别',
    value: 'shareCategoryName',
    align: 'left',
    minWidth: '150px'
  },
  {
    name: '原币',
    value: 'orginalCurrencyDes',
    align: 'left'
  },
  {
    name: '每股面值',
    value: 'priceSharePerOc',
    align: 'right'
  },
  {
    name: '认购股份数',
    value: 'subscribeShare',
    align: 'right',
    minWidth: '140px'
  },
  {
    name: '已缴款股份数',
    value: 'paidShare',
    align: 'right',
    minWidth: '140px'
  },
  {
    name: '持股比例',
    value: 'shareholdingRatio',
    align: 'right'
  },
  {
    name: '表决权比例',
    value: 'votePer',
    align: 'right',
    minWidth: '100px'
  }
]
export const limitCompanyColumns = [
  {
    name: '公司代码',
    value: 'cmhkId',
    align: 'left'
  },
  {
    name: '中文名称',
    value: 'companyChiName',
    align: 'left',
    minWidth: '200px'
  },
  {
    name: '英文名称',
    value: 'companyEngName',
    align: 'left',
    minWidth: '200px'
  },
  {
    name: '所在地区',
    value: 'location',
    align: 'left',
    minWidth: '200px'
  },
  {
    name: '是否实体',
    value: 'entityDesc',
    align: 'left',
    formatter(row) {
      switch (row.isEntity) {
        case '0':
          row.entityDesc = '否'
          break
        case '1':
          row.entityDesc = '是'
          break
      }
      return row.entityDesc
    }
  },
  {
    name: '经营状态',
    value: 'statusDes',
    align: 'left'
  },
  {
    name: '会计核算类型',
    value: 'accountingTypeDes',
    align: 'left',
    minWidth: '120px'
  },
  {
    name: '入股日期',
    value: 'buyTime',
    align: 'left',
    minWidth: '120px'
  },
  {
    name: '委托人',
    value: 'consigner',
    align: 'left'
  },
  {
    name: '原币',
    value: 'orginalCurrencyDes',
    align: 'left'
  },
  {
    name: '认缴注册资本额(原币)',
    value: 'subscribeShareOc',
    align: 'right',
    minWidth: '180px'
  },
  {
    name: '实缴注册资本额(原币)',
    value: 'paidShareOc',
    align: 'right',
    minWidth: '180px'
  },
  {
    name: '出资比例',
    value: 'shareholdingRatio',
    align: 'right'
  },
  {
    name: '表决权比例',
    value: 'votePer',
    align: 'right',
    minWidth: '100px'
  }
]
export const parentColumns = [
  {
    name: '公司代码',
    value: 'cmhkId',
    align: 'left'
  },
  {
    name: '中文名称',
    value: 'companyChiName',
    align: 'left',
    minWidth: '200px'
  },
  {
    name: '英文名称',
    value: 'companyEngName',
    align: 'left',
    minWidth: '200px'
  },
  {
    name: '所在地区',
    value: 'location',
    align: 'left',
    minWidth: '200px'
  },
  {
    name: '是否实体',
    value: 'entityDesc',
    align: 'left',
    formatter(row) {
      switch (row.isEntity) {
        case '0':
          row.entityDesc = '否'
          break
        case '1':
          row.entityDesc = '是'
          break
      }
      return row.entityDesc
    }
  },
  {
    name: '经营状况',
    value: 'statusDes',
    align: 'left'
  },
  {
    name: '会计核算类型',
    value: 'accountingTypeDes',
    align: 'left',
    minWidth: '120px'
  },
  {
    name: '入伙日期',
    value: 'buyTime',
    align: 'left',
    minWidth: '120px'
  },
  {
    name: '委托人',
    value: 'consigner',
    align: 'left'
  },
  {
    name: '合伙人类型',
    value: 'shareType',
    align: 'left',
    minWidth: '120px'
  },
  {
    name: '原币',
    value: 'orginalCurrencyDes',
    align: 'left'
  },
  {
    name: '认缴出资额(原币)',
    value: 'subscribeShareOc',
    align: 'right',
    minWidth: '140px'
  },
  {
    name: '实缴出资额(原币)',
    value: 'paidShareOc',
    align: 'right',
    minWidth: '140px'
  },
  {
    name: '出资比例',
    value: 'shareholdingRatio',
    align: 'right'
  },
  {
    name: '表决权比例',
    value: 'votePer',
    align: 'right',
    minWidth: '100px'
  }
]
export const branchColumns = [
  {
    name: '公司代码',
    value: 'cmhkId',
    align: 'left'
  },
  {
    name: '中文名称',
    value: 'companyChiName',
    align: 'left'
  },
  {
    name: '英文名称',
    value: 'companyEngName',
    align: 'left'
  },
  {
    name: '所在地区',
    value: 'location',
    align: 'left',
  },
  {
    name: '负责人',
    value: 'operName',
    align: 'left'
  },
  {
    name: '成立日期',
    value: 'startDate',
    align: 'left'
  }
]
// 档案
export const docxColumns = [
  {
    name: '档案类型',
    value: 'archivesTypeDes',
    align: 'left'
  },
  {
    name: '档案名称',
    value: 'archivesName',
    align: 'left'
  },
  {
    name: '档案日期',
    value: 'archivesDate',
    align: 'center'
  },
  {
    name: '档案说明',
    value: 'explanation',
    align: 'left'
  }
]
export const stockInforColumns = [
  {
    name: '股票代码',
    value: 'shareCode',
    align: 'center'
  },
  {
    name: '股票简称',
    value: 'shareShortName',
    align: 'center'
  },
  {
    name: '交易币种',
    value: 'currency',
    align: 'center'
  },
  {
    name: '开盘价',
    value: 'startPrices',
    align: 'center'
  },
  {
    name: '收盘价',
    value: 'endPrices',
    align: 'center'
  },
  {
    name: '成交金额',
    value: 'turnoverAmount',
    align: 'center'
  },
  {
    name: '成交量',
    value: 'turnoverNumber',
    align: 'center'
  },
  {
    name: '成交日',
    value: 'tradDate',
    align: 'center'
  }
]
export const fileTableEditColumns = [
  {
    name: '文件名',
    value: 'name',
    align: 'center'
  },
  {
    name: '文件大小',
    value: 'size',
    align: 'center'
  },
  {
    name: '上传时间',
    value: 'fileUploadDate',
    align: 'center'
  },
  {
    name: '上传人',
    value: 'fileUpleader',
    align: 'center'
  },
  {
    name: '文件类型',
    value: 'documentTypeDesc',
    align: 'center',
  },{
    name: '文件细类',
    value: 'documentCategoryDesc',
    align: 'center'
  },
  {
    name: '文件说明',
    value: 'remark',
    align: 'center'
  }
]

